from django.urls import path, re_path, include
from . import views

app_name = 'users'

urlpatterns = [
    #用户注册，确定命名空间为users:register,防止改url影响全局代码
    re_path(r'^register/$',views.RegisterView.as_view(),name='register'),
    #判断用户名是否重复
    re_path(r'^usernames/(?P<username>[a-zA-Z0-9_-]{5,20})/count$',views.UserNameCount.as_view()),
    #判断手机号码是否重复
    re_path(r'^mobiles/(?P<mobile>1[3-9]\d{9}/count$)',views.MobileCountView.as_view()),
    #用户登录
    re_path(r'^login/$',views.LoginView.as_view(),name='login'),
    #用户退出
    re_path(r'^logout/$',views.LogoutView.as_view(),name='logout'),
    #用户中心
    re_path(r'^info/$',views.UserInfoView.as_view(),name='info'),
    #用户邮箱认证绑定
    re_path(r'^emails/$',views.EmailView.as_view()),
    #校验邮箱验证url
    re_path(r'^emails/verification/$',views.VerifyEmail.as_view()),
    #用户中心展示地址
    re_path(r'^addresses/$',views.AddressView.as_view(),name='address'),
    #新增用户地址
    re_path(r'^addresses/create/$',views.AddressCreateView.as_view()),
    #更新和删除地址
    re_path(r'^addresses/(?P<address_id>\d+)/$',views.UpdateDestoryAddressView.as_view()),
    #设置默认地址
    re_path(r'^addresses/(?P<address_id>\d+)/default/$',views.DefaultAddressView.as_view()),
    #修改标题
    re_path(r'^addresses/(?P<address_id>\d+)/title/$',views.UpdateTitleView.as_view()),
    #展示修改密码界面
    re_path(r'^password/$',views.PasswordView.as_view(),name='password'),
    #修改密码
    re_path(r'^password/update/$',views.UpdatePasswordView.as_view(),name='update_password')
]